<?php
/**
 * @version		$Id: view.html.php 16836 2010-05-05 22:50:00Z louis $
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

/**
 * @package		Joomla.Administrator
 * @subpackage	com_content
 */
class AjaxWhoisViewLink extends JView
{
	protected $item;
	protected $form;
	protected $state;

	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		$this->form		= $this->get('Form');
		$this->item		= $this->get('Item');
		$this->state	= $this->get('State');
		
		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		$this->form->bind($this->item);

		$this->addToolbar();
		parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @since	1.6
	 */
	protected function addToolbar()
	{
		JRequest::setVar('hidemainmenu', true);

//		$view = &$this->getView('Links', 'html', 'AjaxWhoisView');
//		$which = $view->state->get('filter.which');
		
//		$whichLink = array("", "_REGISTRATION_", "_TRANSFER_", "_HOSTING_");
		
		$isNew		= ($this->item->id == 0);

		JToolBarHelper::title(JText::_('COM_AJAXWHOIS_'.($isNew ? 'NEW_LINK' : 'EDIT_LINK')), 'link-add');

		JToolBarHelper::apply('link.apply', 'JTOOLBAR_APPLY');
		JToolBarHelper::save('link.save', 'JTOOLBAR_SAVE');
		JToolBarHelper::custom('link.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);

		// If an existing item, can save to a copy.
		if (!$isNew) {
			JToolBarHelper::custom('link.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
		}
		if ($isNew)  {
			JToolBarHelper::cancel('link.cancel', 'JTOOLBAR_CANCEL');
		} else {
			JToolBarHelper::cancel('link.cancel', 'JTOOLBAR_CLOSE');
		}
	}
}